module Taigu {
    /**
     * 主游戏容器
     */
    export class GameContainer extends egret.DisplayObjectContainer {
        /**@private*/
        private stageW: number;
        /**@private*/
        private stageH: number;
        /**背景*/

        private armature: dragonBones.Armature;
        private bb: dragonBones.Armature;
        private mcFactory: egret.MovieClipDataFactory;
        private light: egret.MovieClip;
        private factory: dragonBones.EgretFactory;
        private hs: egret.Bitmap = new egret.Bitmap;
        private wc: egret.Bitmap = new egret.Bitmap;
        private tgh: egret.Bitmap = new egret.Bitmap;
        private smokerRed: egret.Bitmap = new egret.Bitmap;
        private smokerBlue: egret.Bitmap = new egret.Bitmap;
        private tips: egret.Bitmap = new egret.Bitmap;
        private darkness: egret.Bitmap = new egret.Bitmap;
        private balloon: egret.Bitmap = new egret.Bitmap;
        private btn: egret.Bitmap = new egret.Bitmap;
        private btn2: egret.Bitmap = new egret.Bitmap;
        private ar: dragonBones.EgretArmatureDisplay;
        private ar2: dragonBones.EgretArmatureDisplay;
        private pc: number = 1;
        private pcMax: number = 18;
        private smokeMax1: number = 30;
        private redMax: number = 47;
        private blueMax: number = 45;
        private timer360;
        private homeUrl: string = 'http://event.adtiger.cn/taikoo/';
        private points: number[] = [0, 0, 0];
        private pointsPos: number[][][] = [[[1,553.5,412.5],[2,187.5,658.5],[3,560.5,760.45]],[[1,583.5,412.5],[2,206.5,655.5],[3,611.5,732.45]],[[1,583.5,412.5],[2,257.5,638.5],[3,612.5,696.45]],[[1,576.5,406.5],[2,323.5,620.5],[3,610.5,668.5]],[[1,553.5,391.5],[2,418.5,605.5],[3,573.5,638.5]],[[1,451.5,391.5],[2,453.5,608.5],[3,526.5,640.5]],[[1,322.5,395.5],[2,462.5,608.5],[3,527.5,664.5]],[[1,269.5,370.5],[2,505.5,609.5],[3,349.5,632.5]],[[1,258.5,394.5],[2,547.5,622.5],[3,288.5,655.5]],[[1,240.5,416.5],[2,573.5,620.5],[3,276.5,665.5]],[[1,206.5,409.5],[2,563.5,633.5],[3,226.5,692.5]],[[1,212.5,401.5],[2,535.5,626.5],[3,228.5,689.5]],[[1,269.5,367.5],[2,521.5,622.5],[3,239.5,686.5]],[[1,331.5,351.5],[2,465.5,634.5],[3,269.5,730.5]],[[1,307.5,359.5],[2,329.5,607.5],[3,243.5,730.5]],[[1,271.5,346.5],[2,216.5,614.5],[3,258.5,736.5]],[[1,397.5,371.5],[2,180.5,643.5],[3,353.5,735.5]],[[1,484.5,376.5],[2,186.5,655.5],[3,486.5,739.5]]];
        private btnsPos: number[][] = [[526,331,0.9,1.2,0],[104,421,0.8,0.6,0],[407,679,1.7,1.7,0],[208,700,1.4,1.4,0],[631,653,0.8,0.6,0],[473,857,0.7,0.9,0],[592,815,1.1,1.6,1],[234,1113,0.8,0.6,0],[159,893,0.6,0.8,1],[563,569,0.6,0.8,1],[586,474,1.1,0.8,0],[365,1029,1.1,0.8,0]];
        private cloudPos: number[][] = [[687, 717, 2], [305, 676, 2], [146, 752, 3], [555, 304, 1], [626, 752, 3], [546, 770, 3], [619, 590, 2], [505, 301, 2], [605, 425, 2], [526, 388, 3], [449, 665, 2], [171, 702, 1], [205, 762, 1], [250, 651, 3], [312, 794, 3], [402, 780, 3], [408, 543, 3], [442, 449, 3], [356, 482, 1], [432, 608, 1], [460, 519, 3], [542, 479, 3], [563, 550, 2], [356, 652, 2], [588, 700, 3], [534, 658, 3], [485, 566, 1]];
        private blocks: number[][] = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0]];
        private clouds;
        private bs;
        private ox: number;
        private oy: number;
        private oc: number;
        private point1;
        private point2;
        private point3;
        private flash;
        private flashc:egret.SoundChannel;
        private bingoCheck:number[]=[0,0];
        private bingoCount:number=0;
        private helper:egret.Sprite;
        private bx:number=378;
        private by:number=560;
        private ss:number=.3;
        private ssN:number=.3;
        private ssIn:number=.6;
        private ssOut:number=.3;
        private touchPoints: Object = { names: [] }; //{touchid:touch local,names:[ID1,ID2]};
        private distance: number = 0;
        private defAngle: number = 0;
        private touchCon: number = 0;
        private _currentBirdRotation: number = 0;
        private touchMove: number = 0;
        private mx: number;
        private my: number;
        private btnLeft: egret.Bitmap = new egret.Bitmap;
        private btnRight: egret.Bitmap = new egret.Bitmap;
        private btnN: egret.Bitmap = new egret.Bitmap;
        private btnZoomIn: egret.Bitmap = new egret.Bitmap;
        private btnZoomOut: egret.Bitmap = new egret.Bitmap;
        private btnSkip: egret.Bitmap = new egret.Bitmap;
        private os:number;
        private bw:number;
        private bh:number;
        private tw1:egret.Tween;
        private tw2:egret.Tween;
        private twSound:egret.Tween;
        private light1: egret.Bitmap = new egret.Bitmap;
        private light2: egret.Bitmap = new egret.Bitmap;
        public constructor() {
            super();
            this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
        }

        /**初始化*/
        private onAddToStage(event: egret.Event) {
            this.removeEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
            this.createGameScene();
        }


        /**创建游戏场景*/
        private createGameScene(): void {

            this.stageW = this.stage.stageWidth;
            this.stageH = this.stage.stageHeight;
            
            var textField = new egret.TextField();
            this.addChild(textField);
            textField.size = 50;
            textField.bold = true;
            textField.textColor = 0xc1272d;
            textField.textAlign = "LEFT";
            textField.text = 'Loading...100%';
            textField.anchorOffsetX=textField.textWidth/2;
            textField.anchorOffsetY = textField.textHeight / 2;
            textField.x=this.stageW/2;
            textField.y=600;
            var btn = new egret.Bitmap(RES.getRes("btnStart"));
            btn.anchorOffsetX = btn.width / 2;
            btn.anchorOffsetY = btn.height / 2;
            btn.x = this.stageW/2;
            btn.y =textField.y+200;// this.stageH/2;
            this.addChild(btn);
            btn.touchEnabled = true;
            btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.showIntro, this);
            //this.showIntro();
            //this.showPoints();
        }
        //片头动画
        private showIntro(): void {
            this.removeChildren();
            this.flash = RES.getRes("flash");
            this.flashc=this.flash.play(0,11);
            this.flashc.volume=0;
            //定义dragonBones.EgretFactory对象
            this.factory = new dragonBones.EgretFactory();
            this.factory.parseDragonBonesData(RES.getRes("ani1s"));
            this.factory.parseTextureAtlasData(RES.getRes("ani1t"), RES.getRes("ani1i"));
            //直接生成骨骼动画显示对象，该对象实现IArmatureDisplay接口
            //片头
            var ar: dragonBones.EgretArmatureDisplay = this.factory.buildArmatureDisplay("ani1");
            ar.animation.play("ani", 1);
            //ar.x = -750;
            //ar.y = -1206;
            this.addChild(ar);
            ar.addEventListener(dragonBones.AnimationEvent.COMPLETE, this.introDone, this);
            //闪光灯
            this.ar = ar;
            var apt = new egret.Bitmap(RES.getRes("blank"));
            apt.alpha = 0;
            this.addChild(apt);
            var tw = egret.Tween.get(apt, { loop: false });
            tw.wait(4000).call(function () {
                this.flashc.volume=1;
            }, this).to({ alpha: 1 }, 200, egret.Ease.bounceIn).to({ alpha: 0 }, 0).wait(300).to({ alpha: 1 }, 200, egret.Ease.bounceIn).to({ alpha: 0 }, 0).wait(300).to({ alpha: 1 }, 300, egret.Ease.bounceIn).to({ alpha: 0 }, 0).call(function () {
                //this.flashc.stop();
                console.log('闪光灯');
                this.removeChild(apt);
            }, this);
            this.twSound=tw;
            var btnSkip = new egret.Bitmap(RES.getRes("btnSkip"));
            btnSkip.anchorOffsetX = btnSkip.width / 2;
            btnSkip.anchorOffsetY = btnSkip.height / 2;
            btnSkip.x = 595;
            btnSkip.y = 1110;
            btnSkip.scaleX=btnSkip.scaleY=.5;
            this.addChild(btnSkip);
            this.btnSkip=btnSkip
            btnSkip.touchEnabled = true;
            btnSkip.addEventListener(egret.TouchEvent.TOUCH_TAP, this.showWC, this);
        }
        //片头结束
        private introDone(): void {
            //egret.setTimeout(this.showWC, this, 500);
            //console.log('introDone');
            if (this.btnSkip.$hasAddToStage) {
                //console.log(this.btnSkip);
                var btn = new egret.Bitmap(RES.getRes("btn"));
                btn.anchorOffsetX = btn.width / 2;
                btn.anchorOffsetY = btn.height / 2;
                btn.x = 360;
                btn.y = 735;
                btn.scaleX = 3;
                btn.scaleY = 1.5;
                this.addChild(btn);
                btn.touchEnabled = true;
                btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.showWC, this);
                var hand = new egret.Bitmap(RES.getRes("hand"));
                //console.log(hand.width);
                hand.anchorOffsetX = hand.width / 2;
                hand.anchorOffsetY = hand.height / 2;
                hand.x = 385;
                hand.y = 860;
                this.addChild(hand);
                var tw = egret.Tween.get(hand, { loop: true });
                tw.to({ y: 850 }, 500, egret.Ease.bounceOut).to({ y: 860 }, 500, egret.Ease.bounceIn);
                this.removeChild(this.btnSkip);
            }
        }
        //水彩进场
        private showWC(): void {
            this.twSound.setPaused(true);
            this.twSound.pause();
            this.removeChildren();
            //this.removeChild(this.ar);
            //this.tgh = new egret.Bitmap(RES.getRes("pic1"));
            this.smokerRed = new egret.Bitmap(RES.getRes("smoke1"));
            this.addChild(this.smokerRed);
            /*this.smokerBlue = new egret.Bitmap(RES.getRes("smokeBlue1"));
            this.smokerBlue.rotation=180;
            this.smokerBlue.x=this.stageW;
            this.smokerBlue.y=this.stageH;
            this.addChild(this.smokerBlue);
            this.smokerBlue.visible=false;*/
            this.wc = new egret.Bitmap(RES.getRes("introBg"));
            //this.wc.alpha=0;
            this.addChild(this.wc);
            this.hs = new egret.Bitmap(RES.getRes("handStyle"));
            this.hs.alpha = 0;
            this.addChild(this.hs);

            //this.tgh.alpha=0;
            /*var colorMatrix = [
                1,0,0,0,100,
                0,1,0,0,20,
                0,0,1,0,0,
                0,0,0,1,0
            ];
            var colorFlilter = new egret.ColorMatrixFilter(colorMatrix);
            this.tgh.filters = [colorFlilter];*/

            /*this.clouds=[];
            //console.log('length='+this.cloudPos.length)
            for (var i = 0; i < this.cloudPos.length; i++) {
                var cloud = new egret.Bitmap(RES.getRes("pics.cloud" + this.cloudPos[i][2]));
                //console.log(cloud.width);
                cloud.anchorOffsetX = cloud.width / 2;
                cloud.anchorOffsetY = cloud.height / 2;
                cloud.x = this.stageW + 150;
                cloud.y = this.cloudPos[i][1];
                this.addChild(cloud);
                var tw = egret.Tween.get(cloud);
                tw.wait(1000 + Math.round(Math.random() * 2000)).to({ x: this.cloudPos[i][0] }, Math.round(Math.random() * 1000) + 1000).call(function () {
                    //this.removeChild(cloud);
                }, this);
                this.clouds.push(cloud);
            }*/

            //this.tgh.scaleX=this.tgh.scaleY=1.2;
            this.timer360 = egret.setInterval(this.smoking, this, 100);
            //egret.setTimeout(this.buildBlock, this, 6000);
        }
        //烟雾逐幀动画
        private smoking(): void {
            this.pc++;
            this.smokerRed.texture = RES.getRes("smoke" + this.pc);
            //console.log(this.pc)
            if (this.pc == this.smokeMax1-9) {
                //egret.clearInterval(this.timer360);
                //this.showPoints();
                //var tw2 = egret.Tween.get(this.smoker);
                //tw2.wait(1000).to({ alpha:0 }, 1000);
                // var tw3 = egret.Tween.get(this.wc);
                //tw3.to({ alpha:1 }, 1000);
                var tw = egret.Tween.get(this.hs);
                tw.to({ alpha: 1 }, 1000).call(function () {
                    egret.clearInterval(this.timer360);
                }, this).wait(1000).to({ alpha: 0 }, 1000).call(function () {
                    //this.pc=1;
                    //this.smokerBlue.visible=true;
                    //this.timer360 = egret.setInterval(this.smokingBlue, this, 100);
                    this.buildBlock2();
                }, this);/*call(function () {
                    this.pc=0;
                    this.timer360 = egret.setInterval(this.smokingOut, this, 100);
                    var tw4 = egret.Tween.get(this.smoker);
                    tw4.to({ alpha:1 }, 500);
                }, this).to({ alpha:0 }, 1000);*/
            }
        }
        private smokingRed(): void {
            this.pc++;
            this.smokerRed.texture = RES.getRes("smokeRed" + this.pc);
            //console.log(this.pc)
            if (this.pc == this.redMax - 10) {
                //egret.clearInterval(this.timer360);
                //this.showPoints();
                //var tw2 = egret.Tween.get(this.smoker);
                //tw2.wait(1000).to({ alpha:0 }, 1000);
                // var tw3 = egret.Tween.get(this.wc);
                //tw3.to({ alpha:1 }, 1000);
                var tw = egret.Tween.get(this.hs);
                tw.to({ alpha: 1 }, 1000).call(function () {
                    egret.clearInterval(this.timer360);
                }, this).wait(1000).to({ alpha: 0 }, 1000).call(function () {
                    console.log("smokeblue")
                    this.pc = 1;
                    this.smokerBlue.visible = true;
                    this.timer360 = egret.setInterval(this.smokingBlue, this, 100);
                    //this.buildBlock();
                }, this);/*call(function () {
                    this.pc=0;
                    this.timer360 = egret.setInterval(this.smokingOut, this, 100);
                    var tw4 = egret.Tween.get(this.smoker);
                    tw4.to({ alpha:1 }, 500);
                }, this).to({ alpha:0 }, 1000);*/
            }
        }
        private smokingBlue(): void {
            this.pc++;
            this.smokerBlue.texture = RES.getRes("smokeBlue" + this.pc);
            if (this.pc == this.blueMax - 30) {
                this.buildBlock();
            } else if (this.pc == this.blueMax) {
                egret.clearInterval(this.timer360);
                this.pc = 1;
                this.timer360 = egret.setInterval(this.show360, this, 100);
                //this.buildBlock();
            }
        }

        private buildBlock(): void {
            this.tgh = new egret.Bitmap(RES.getRes("pic1"));
            this.tgh.x = 378;
            this.tgh.y = 560;
            this.tgh.anchorOffsetX = this.tgh.width / 2;
            this.tgh.anchorOffsetY = this.tgh.height / 2;
            this.tgh.alpha = 0;
            this.addChild(this.tgh);
            var tw = egret.Tween.get(this.tgh);
            tw.to({ alpha: 1 }, 1000).call(function () {
                // this.removeChild(this.wc);
            }, this);
        }
        private buildBlock2(): void {
            /*var tw = egret.Tween.get(this.wc);
               tw.to({ alpha: 0 },  1000).call(function () {
                   this.removeChild(this.wc);
               }, this);
           for (var i = 0; i < this.clouds.length; i++) {
               var cloud=this.clouds[i];
               var tw = egret.Tween.get(cloud);
               tw.wait(1000).to({ x: cloud.x-1000 }, 1000);
           }*/
            var count = 0;
            var dis = 46;
            this.bs = [];
            for (var i = 0; i < this.blocks.length; i++) {
                var k = 0;
                var aa = [];
                var al = 0;
                for (var j = 0; j < this.blocks[i].length; j++) {
                    if (this.blocks[i][j] == 1) {
                        var block = new egret.Bitmap(RES.getRes("pics.building" + count));
                        block.anchorOffsetX = block.width / 2;
                        block.anchorOffsetY = block.height / 2;
                        block.x = 1 + j * dis;
                        block.y = 767 - i * dis;
                        block.scaleX = block.scaleY = 1.3;
                        block.alpha = 0;
                        this.addChild(block);
                        aa.push(count);
                        count++;
                        this.bs.push(block);

                    }
                }
                al = aa.length
                var bb = [];
                for (var j = 0; j < al; j++) {
                    var rnd = Math.floor(Math.random() * aa.length);
                    bb.push(aa[rnd]);
                    aa.splice(rnd, 1);
                }
                for (var j = 0; j < bb.length; j++) {
                    var bbb = this.bs[bb[j]];
                    //console.log(bbb.x);
                    var tw = egret.Tween.get(bbb);
                    tw.wait((count - j) * 100).to({ alpha: 1, scaleX: 1, scaleY: 1 }, 500, egret.Ease.bounceIn);/*.wait(11000 - (count-j) * 100).call(function () {
                      //  this.removeChild(block);
                    }, this);*/
                }
            }
            egret.setTimeout(this.fadeWC, this, 9000);
            //egret.setTimeout(this.clearCloud, this, 2000);
        }
        private clearCloud(): void {
            for (var i = 0; i < this.clouds.length; i++) {
                // var cloud=this.clouds[i];
                this.removeChild(this.clouds[i]);
            }
        }
        private fadeWC(): void {
            for (var i = 0; i < this.bs.length; i++) {
                // var cloud=this.clouds[i];
                this.removeChild(this.bs[i]);
            }
            this.tgh = new egret.Bitmap(RES.getRes("pic1"));
            this.tgh.x = this.bx;
            this.tgh.y = this.by;
            //this.tgh.x = 375;
            //this.tgh.y = 603;
            this.tgh.anchorOffsetX = this.tgh.width / 2;
            this.tgh.anchorOffsetY = this.tgh.height / 2;
            this.tgh.scaleX=this.tgh.scaleY=this.ss;
            this.addChild(this.tgh);
            //this.tgh.visible = false;
            //this.addChild(this.tgh);
            /*var move = egret.Tween.get(this.wc);
            move.to({ alpha: 0 }, 1000);*/
            //egret.setTimeout(this.showBuilding, this, 1000);
             /*var tw = egret.Tween.get(this.tgh);
                tw.to({ scaleX: 1,scaleY:1 }, 1000).call(function () {
                    this.zoomIn();
                }, this);*/
                this.pc = 1;
                this.timer360 = egret.setInterval(this.show360, this, 100);
        }
        /*private zoomIn():void{
            this.pc = 1;
            this.timer360 = egret.setInterval(this.show360, this, 100);
        }*/
        private showBuilding(): void {
            //var move = egret.Tween.get(this.tgh);
            //move.to({ scaleX: 1, scaleY: 1 }, 1000);
            //this.addChild(this.wc);
            this.pc = 1;
            this.timer360 = egret.setInterval(this.show360, this, 100);
        }
        private show360(): void {
            this.pc++;
            this.pc > this.pcMax ? this.pc = 1 : undefined;
            this.tgh.texture = RES.getRes("pic" + this.pc);
            this.tgh.x = this.bx;
            this.tgh.y = this.by;
            this.tgh.anchorOffsetX = this.tgh.width / 2;
            this.tgh.anchorOffsetY = this.tgh.height / 2;
            if (this.pc == 1) {
                egret.clearInterval(this.timer360);
                this.showPoints();
            }
        }
        private md(evt: egret.TouchEvent): void {
            //var dis:number;
            var tx: number = evt.localX;
            var ty: number = evt.localY;
            this.ox = tx;
            this.oy = ty;
            this.oc = this.pc;
            this.disTips();
        }
        private mm(evt: egret.TouchEvent): void {
            var tx: number = evt.localX;
            var ty: number = evt.localY;
            var count = Math.round((tx - this.ox) / 10);
            count = count % this.pcMax;
            this.pc = this.oc - count;
            this.pc > this.pcMax ? this.pc -= this.pcMax : undefined;
            this.pc < 1 ? this.pc += this.pcMax : undefined;
            //this.ox = tx;
            //this.oy = ty;
            this.refresh360();
        }
        private goPage(): void {
            window.location.href = this.homeUrl + 'lottery.php';
        }
        private showPoints(): void {
            this.removeChildren();

            var gameOk = '';
            for (var i = 0; i < this.points.length; i++) {
                if (this.points[i] == 1) {
                    gameOk += (i + 1) + '';
                }
            }
            //gameOk = true;
            var nickname = document.getElementById("nickname");
            var getname = window.sessionStorage.getItem('nickname') || "nickname";
            nickname.innerHTML = getname;

            if (gameOk.length > 1) {
                nickname.style.display = "block";
                var bg = new egret.Bitmap(RES.getRes("pageEnd01"));
                this.addChild(bg);
                if (gameOk == '12' || gameOk == '23') {
                    var bg2 = new egret.Bitmap(RES.getRes("e" + gameOk));
                    bg2.y = 320;
                    this.addChild(bg2);
                }
                var btn = new egret.Bitmap(RES.getRes("btnGo"));
                btn.anchorOffsetX = btn.width / 2;
                btn.anchorOffsetY = btn.height / 2;
                btn.x = 393;
                btn.y = 1060;
                //btn.scaleX=btn.scaleY=1.1;
                this.addChild(btn);
                btn.touchEnabled = true;
                btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.goPage, this);
                var tw = egret.Tween.get(btn, { loop: true });
                tw.to({ scaleX: 1.1, scaleY: 1.1 }, 1000, egret.Ease.bounceIn).wait(500).to({ scaleX: 1, scaleY: 1 }, 500, egret.Ease.bounceOut).wait(1000);
                
        } else {
                this.ss=this.ssN;
                this.smokerRed = new egret.Bitmap(RES.getRes("smoke" + this.smokeMax1));
                this.addChild(this.smokerRed);
                /*this.smokerBlue = new egret.Bitmap(RES.getRes("smokeBlue" + this.blueMax));
                this.smokerBlue.rotation = 180;
                this.smokerBlue.x = this.stageW;
                this.smokerBlue.y = this.stageH;
                this.addChild(this.smokerBlue);*/
                this.wc = new egret.Bitmap(RES.getRes("introBg"));
                this.addChild(this.wc);
                this.tgh = new egret.Bitmap(RES.getRes("pic1"));
                this.tgh.x = this.bx;
                this.tgh.y = this.by;
                //this.tgh.x = 375;
                //this.tgh.y = 603;
                this.tgh.anchorOffsetX = this.tgh.width / 2;
                this.tgh.anchorOffsetY = this.tgh.height / 2;
                this.tgh.scaleX=this.tgh.scaleY=this.ss;
                this.addChild(this.tgh);
                var tw = egret.Tween.get(this.tgh);
                tw.wait(1500).to({ scaleX: this.ssIn, scaleY: this.ssIn }, 500).call(function () {
                //egret.clearInterval(this.timer360);
                /*this.ss=this.ssIn;
                this.btnZoomOut.visible=true;*/
                this.zoomIn();
                this.wc.touchEnabled = true;
                this.wc.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.md, this);
                this.wc.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.mm, this);
                }, this);
                
                for (var i = 0; i < 3; i++) {
                    this['point'+(i+1)]=null;
                    var point=new egret.Sprite();
                        this['point'+(i+1)]=point;
                        this.addChild(point);
                        var apt = new egret.Bitmap(RES.getRes("point"+(i+1)));
                        apt.anchorOffsetX = apt.width / 2;
                        apt.anchorOffsetY = apt.height / 2;
                        //apt.x = this.pointsPos[0][i][1];
                        //apt.y = this.pointsPos[0][i][2];
                        apt.alpha = .7;
                        point.addChild(apt);
                        var tw = egret.Tween.get(apt,{loop:true});
                        tw.to({ scaleX: 2.5, scaleY: 2.5, alpha: 0 }, 500).to({ scaleX: 2.5, scaleY: 2.5, alpha: 0 }, 500).to({alpha:0}).call(function () {
                      //egret.clearInterval(this.timer360);
                        }, this);
                        var pt = new egret.Bitmap(RES.getRes("point"+(i+1)));
                        pt.anchorOffsetX = pt.width / 2;
                        pt.anchorOffsetY = pt.height / 2;
                        point.addChild(pt);
                        /*var tw2 = egret.Tween.get(pt);
                        tw2.wait(1000).to({alpha:0}).call(function () {
                      //egret.clearInterval(this.timer360);
                        }, this);*/
                        
                        var btn = new egret.Bitmap(RES.getRes("btn"));
                        btn.anchorOffsetX = btn.width / 2;
                        btn.anchorOffsetY = btn.height / 2;
                        // btn.x = this.pointsPos[0][i][1];
                        // btn.y = this.pointsPos[0][i][2];
                        point.addChild(btn);
                      //  btn.touchEnabled = true;
                      //  btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.pointTap, this);
                        
                        // var btn = new egret.Bitmap(RES.getRes("point"+(i+1)));
                       // var btn = new egret.Bitmap(RES.getRes("btn"));
                    //     btn.anchorOffsetX = 32;
                    //     btn.anchorOffsetY = 198;
                    //     btn.scaleX=btn.scaleY=.01;
                    //     btn.alpha=0;
                    //     //btn.x = this.pointsPos[0][i][1];
                    //     //btn.y = this.pointsPos[0][i][2];
                    //     var tw3 = egret.Tween.get(btn);
                    //     tw3.wait(1000).to({ scaleX: .4, scaleY: .4, alpha: 1 }, 500,egret.Ease.bounceIn).call(function () {
                    //   //egret.clearInterval(this.timer360);
                    //     }, this);
                     //   point.addChild(btn);
                        point.touchEnabled = true;
                        point.addEventListener(egret.TouchEvent.TOUCH_TAP, this.pointTap, this);
                        point.x = this.pointsPos[0][i][1];
                        point.y = this.pointsPos[0][i][2];
                        var tw4 = egret.Tween.get(point);
                        tw4.wait(1500).to({x:this.bx+(this.pointsPos[this.pc - 1][i][1]-this.bx)*2,y:this.by+(this.pointsPos[this.pc - 1][i][2]-this.by)*2},500);
                   /* if (this.points[i] == 1) {
                        //point.touchEnabled=false;
                        var pointDone = new egret.Bitmap(RES.getRes("pointDone"));
                        pointDone.anchorOffsetX = pointDone.width/2;
                        pointDone.anchorOffsetY = pointDone.height/2;
                        pointDone.scaleX=pointDone.scaleY=.01;
                        pointDone.alpha=0;
                        pointDone.x = 120;
                        pointDone.y = -13;
                        var tw4 = egret.Tween.get(pointDone);
                        tw4.wait(1500).to({scaleX:1,scaleY:1, alpha: 1 }, 500,egret.Ease.bounceIn).call(function () {
                      //egret.clearInterval(this.timer360);
                        }, this);
                        point.addChild(pointDone);
                        //console.log('pointDone'+i);
                    }*/
                    
                }
                /*var tips = new egret.Bitmap(RES.getRes("tips360"));
                tips.anchorOffsetX = tips.width / 2;
                tips.anchorOffsetY = tips.height / 2;
                tips.x = 250;//this.stageW / 2;
                tips.y = 220;//this.stageH / 2;
                tips.scaleX = tips.scaleY = .8;
                this.addChild(tips);
                var tw = egret.Tween.get(tips, { loop: false });
                tw.to({ scaleX: 1, scaleY: 1 }, 500, egret.Ease.bounceIn).wait(5000).call(function () {
                    this.disTips();
                }, this);
                this.tips = tips;*/
                var btnHelp = new egret.Bitmap(RES.getRes("btnHelp"));
                btnHelp.anchorOffsetX = btnHelp.width / 2;
                btnHelp.anchorOffsetY = btnHelp.height / 2;
                btnHelp.x = this.stageW / 2;
                btnHelp.y = 1070;
                this.addChild(btnHelp);
                btnHelp.touchEnabled = true;
                btnHelp.addEventListener(egret.TouchEvent.TOUCH_TAP, this.showHelp, this);
                this.helper=new egret.Sprite();
                this.addChild(this.helper)
                /*this.btnLeft = new egret.Bitmap(RES.getRes("btnLeft"));
                this.btnLeft.anchorOffsetX = this.btnLeft.width / 2;
                this.btnLeft.anchorOffsetY = this.btnLeft.height / 2;
                this.btnLeft.x = 250;
                this.btnLeft.y = 930;
                this.addChild(this.btnLeft);
                this.btnLeft.touchEnabled = true;
                this.btnLeft.addEventListener(egret.TouchEvent.TOUCH_TAP, this.turnLeft, this);
                this.btnRight = new egret.Bitmap(RES.getRes("btnRight"));
                this.btnRight.anchorOffsetX = this.btnRight.width / 2;
                this.btnRight.anchorOffsetY = this.btnRight.height / 2;
                this.btnRight.x = 500;
                this.btnRight.y = 930;
                this.addChild(this.btnRight);
                this.btnRight.touchEnabled = true;
                this.btnRight.addEventListener(egret.TouchEvent.TOUCH_TAP, this.turnRight, this);
                this.btnN = new egret.Bitmap(RES.getRes("btnNormal"));
                this.btnN.anchorOffsetX = this.btnN.width / 2;
                this.btnN.anchorOffsetY = this.btnN.height / 2;
                this.btnN.x = 375;
                this.btnN.y = 930;
                this.addChild(this.btnN);
                this.btnN.touchEnabled = true;
                this.btnN.addEventListener(egret.TouchEvent.TOUCH_TAP, this.goNormal, this);
                this.btnLeft.visible=false;
                this.btnRight.visible=false;*/
                //this.btnN.visible=false;
                this.btnZoomIn = new egret.Bitmap(RES.getRes("btnZoomIn"));
                this.btnZoomIn.anchorOffsetX = this.btnZoomIn.width / 2;
                this.btnZoomIn.anchorOffsetY = this.btnZoomIn.height / 2;
                this.btnZoomIn.x = 375;
                this.btnZoomIn.y = 930;
                this.addChild(this.btnZoomIn);
                this.btnZoomIn.touchEnabled = true;
                this.btnZoomIn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.zoomIn, this);
                this.btnZoomIn.visible=false;
                this.btnZoomOut = new egret.Bitmap(RES.getRes("btnZoomOut"));
                this.btnZoomOut.anchorOffsetX = this.btnZoomOut.width / 2;
                this.btnZoomOut.anchorOffsetY = this.btnZoomOut.height / 2;
                this.btnZoomOut.x = 375;
                this.btnZoomOut.y = 930;
                this.addChild(this.btnZoomOut);
                this.btnZoomOut.touchEnabled = true;
                this.btnZoomOut.addEventListener(egret.TouchEvent.TOUCH_TAP, this.zoomOut, this);
                this.btnZoomOut.visible=false;
                // this.btnZoomIn.alpha=0;
                // this.btnZoomOut.alpha=0;
                /*this.wc.touchEnabled = true;
                this.wc.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.mouseDown, this);
                this.wc.addEventListener(egret.TouchEvent.TOUCH_END, this.mouseUp, this);
                this.wc.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, this.mouseUp, this);
                this.wc.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.mouseMove, this);
                this.os=1;*/
                
            }
        }
        private zoomIn():void{
            this.ss=this.ssIn;
            this.tgh.scaleX=this.tgh.scaleY=this.ss;
            this.refresh360();
            this.btnZoomOut.visible=true;
            this.btnZoomIn.visible=false;
        }
        private zoomOut():void{
            this.ss=this.ssOut;
            this.tgh.scaleX=this.tgh.scaleY=this.ss;
            this.refresh360();
            this.btnZoomIn.visible=true;
            this.btnZoomOut.visible=false;
        }
        private turnLeft():void {
            this.pc--;
            this.pc<1 ? this.pc=this.pcMax : undefined;
            this.refresh360()
        }
        private turnRight():void {
            this.pc++;
            this.pc>this.pcMax ? this.pc=1 : undefined;
            this.refresh360()
        }
        private goNormal():void {
            this.tgh.x = this.bx;
            this.tgh.y = this.by;
            this.tgh.width=this.bw;
            this.tgh.height=this.bh;
            this.tgh.anchorOffsetX = this.tgh.width / 2;
            this.tgh.anchorOffsetY = this.tgh.height / 2;
            this.tgh.scaleX=this.tgh.scaleY=this.ss;
            this.btnLeft.visible=true;
            this.btnRight.visible=true;
            this.btnN.visible=false;
        }
        private refresh360(): void {
            this.tgh.texture = RES.getRes("pic" + this.pc);
            this.tgh.x = this.bx;
            this.tgh.y = this.by;
            this.tgh.anchorOffsetX = this.tgh.width / 2;
            this.tgh.anchorOffsetY = this.tgh.height / 2;
            for (var i = 0; i < 3; i++) {
                var point = this['point' + (i + 1)];
                point.x = this.bx+(this.pointsPos[this.pc - 1][i][1]-this.bx)*this.ss/this.ssOut;
                point.y = this.by+(this.pointsPos[this.pc - 1][i][2]-this.by)*this.ss/this.ssOut;
            }
            this.bw=this.tgh.width;
            this.bh=this.tgh.height;
        }
        private mouseDown(evt: egret.TouchEvent) {
            if (this.touchPoints[evt.touchPointID] == null) {
                this.touchPoints[evt.touchPointID] = new egret.Point(evt.stageX, evt.stageY);
                this.touchPoints["names"].push(evt.touchPointID);
            }
            this.touchCon++;

            if (this.touchCon == 2) {
                this.distance = this.getTouchDistance();

                //this.defAngle = this.getTouchAngle();
                this.touchMove = 0;
            } else {
                if (this.touchCon > 1) {
                    this.touchMove = 0;
                } else {
                    this.touchMove = 1;
                    this.mx = evt.localX;
                    this.my = evt.localY;
                }
            }

        }

        private mouseMove(evt: egret.TouchEvent) {
            //egret.log("touch move:"+evt.touchPointID);

            this.touchPoints[evt.touchPointID].x = evt.stageX;
            this.touchPoints[evt.touchPointID].y = evt.stageY;
            if (this.touchCon == 2) {
                var newdistance = this.getTouchDistance();
                var ss =newdistance / this.distance*this.ss;
                //ss>1 ? ss=1 : (ss<this.ss ? ss=this.ss : undefined);
                if(ss*this.tgh.width>this.bw)
                {
                    ss=this.bw/this.tgh.width;
                }else if(ss*this.width<this.bw*this.ss)
                {
                    ss=this.bw*this.ss/this.tgh.width;
                }
                this.tgh.scaleX = ss; 
                this.tgh.scaleY = ss;
                //egret.log(ss);
                if(ss*this.width<=this.bw*this.ss){
                    this.btnN.visible=false;
                    this.btnLeft.visible=true;
                    this.btnRight.visible=true;
                }else{
                    this.btnN.visible=true;
                    this.btnLeft.visible=false;
                    this.btnRight.visible=false;
                }
                // var newangle = this.getTouchAngle();
                // this.tgh.rotation = this._currentBirdRotation + newangle - this.defAngle;
            }
            if (this.touchMove == 1) {
                /*
            this.tgh.anchorOffsetX = this.tgh.width / 2;
            this.tgh.anchorOffsetY = this.tgh.height / 2;
            */
                this.tgh.x += evt.localX - this.mx;
                this.tgh.y += evt.localY - this.my;
                this.mx = evt.localX;
                this.my = evt.localY;
            }
        }

        private mouseUp(evt: egret.TouchEvent) {
            delete this.touchPoints[evt.touchPointID];

            var index: number = this.touchPoints["names"].indexOf(evt.touchPointID);
            if (index >= 0) {
                this.touchPoints["names"].splice(index, 1);
            }
            this.touchMove = 0;
            this.touchCon--;
            //
            this.tgh.width *= this.tgh.scaleX/this.ss;
            this.tgh.height *= this.tgh.scaleY/this.ss;
            this.tgh.scaleX = this.ss;
            this.tgh.scaleY = this.ss;
            this.tgh.anchorOffsetX = this.tgh.width / 2;
            this.tgh.anchorOffsetY = this.tgh.height / 2;
            //this.os=this.tgh.scaleX;
            //this._currentBirdRotation = this.tgh.rotation;

        }

        private getTouchDistance(): number {
            var _distance: number = 0;
            var names = this.touchPoints["names"];
            //egret.Point.interpolate
            _distance = egret.Point.distance(this.touchPoints[names[names.length - 1]],
                this.touchPoints[names[names.length - 2]]);
            return _distance;
        }

        /*private c: number = 0.017453292; //2PI/360
        private getTouchAngle(): number {
            var ang: number = 0;
            var names = this.touchPoints["names"];
            var p1: egret.Point = this.touchPoints[names[names.length - 1]];
            var p2: egret.Point = this.touchPoints[names[names.length - 2]];

            ang = Math.atan2((p1.y - p2.y), (p1.x - p2.x)) / this.c;
            return ang;
    }*/
        private showHelp(): void {
            var dark = new egret.Bitmap(RES.getRes("darkness"));
            this.helper.addChild(dark);
            dark.touchEnabled = true;
            var apt = new egret.Bitmap(RES.getRes("tips360"));
            apt.anchorOffsetX = apt.width / 2;
            apt.anchorOffsetY = apt.height / 2;
            apt.x = this.stageW / 2;
            apt.y = this.stageH / 2;
            apt.scaleX = apt.scaleY = .8;
            this.helper.addChild(apt);
            var tw = egret.Tween.get(apt, { loop: false });
            tw.to({ scaleX: 1, scaleY: 1 }, 500, egret.Ease.bounceIn);
            var btn = new egret.Bitmap(RES.getRes("btnHelpClose"));
            btn.anchorOffsetX = btn.width / 2;
            btn.anchorOffsetY = btn.height / 2;
            btn.x = apt.x;
            btn.y = apt.y + apt.height / 2+btn.height / 2+30;
            this.helper.addChild(btn);
            btn.touchEnabled = true;
            btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.disHelp, this);
            this.btnZoomIn.visible=false;
                this.btnZoomOut.visible=false;
        }
        private disHelp(): void {
            this.helper.removeChildren();
            if(this.ss==this.ssOut){
                this.btnZoomIn.visible=true;
            }else{
                this.btnZoomOut.visible=true;
            }
            //this.removeChild(this.helper);
        }
        private pointTap(event: egret.Event): void {
            // this.wc.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.mouseDown, this);
            // this.wc.removeEventListener(egret.TouchEvent.TOUCH_END, this.mouseUp, this);
            // this.wc.removeEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, this.mouseUp, this);
            // this.wc.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.mouseMove, this);
            this.wc.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.md, this);
            this.wc.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.mm, this);
            var count = 0;
            for (var i = 0; i < this.points.length; i++) {
                if (this['point'+(i+1)]==event.target) {
                    count = i;
                    break;
                }
            }
            this.goGame(count);
        }
        private goGame(count): void {
            //console.log(count);
            switch (count) {
                case 0:
                    this.removeChildren();
                    this.factory = new dragonBones.EgretFactory();
                    this.factory.parseDragonBonesData(RES.getRes("lights"));
                    this.factory.parseTextureAtlasData(RES.getRes("lightt"), RES.getRes("lighti"));
                    //直接生成骨骼动画显示对象，该对象实现IArmatureDisplay接口
                    var ar: dragonBones.EgretArmatureDisplay = this.factory.buildArmatureDisplay("light");
                    ar.animation.gotoAndStop("ani");
                    ar.x = 302;
                    ar.y = 596;
                    this.addChild(ar);
                    this.ar = ar;
                    var bg = new egret.Bitmap(RES.getRes("game1bg"));
                    this.addChild(bg);
                    var btn = new egret.Bitmap(RES.getRes("balloon"));
                    btn.anchorOffsetX = btn.width / 2;
                    btn.anchorOffsetY = btn.height / 2;
                    btn.x = 663;
                    btn.y = 1140;
                    this.addChild(btn);
                    btn.touchEnabled = true;
                    btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.game1start, this);
                    this.balloon = btn;
                    break;
                case 1:
                    this.removeChildren();
                    var bg = new egret.Bitmap(RES.getRes("game2bg"));
                    this.addChild(bg);
                    bg.touchEnabled = true;
                    bg.addEventListener(egret.TouchEvent.TOUCH_TAP, this.bingoError, this);
                    for (var i = 0; i < this.bingoCheck.length; i++) {
                        this.bingoCheck[i]=0;
                    }
                    this.bingoCount=0;
                    for (var i = 0; i < this.btnsPos.length; i++) {
                        var btn = new egret.Bitmap(RES.getRes("btn"));
                        btn.anchorOffsetX = btn.width / 2;
                        btn.anchorOffsetY = btn.height / 2;
                        btn.x = this.btnsPos[i][0];
                        btn.y = this.btnsPos[i][1];
                        btn.scaleX = this.btnsPos[i][2];
                        btn.scaleY = this.btnsPos[i][3];
                        this.addChild(btn);
                        btn.touchEnabled = true;
                        btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.game2check, this);
                    }
                    break;
                case 2:
                    this.removeChildren();
                    var bg = new egret.Bitmap(RES.getRes("game3bg"));
                    this.addChild(bg);
                    this.factory = new dragonBones.EgretFactory();
                    this.factory.parseDragonBonesData(RES.getRes("cars"));
                    this.factory.parseTextureAtlasData(RES.getRes("cart"), RES.getRes("cari"));
                    //直接生成骨骼动画显示对象，该对象实现IArmatureDisplay接口
                    var ar: dragonBones.EgretArmatureDisplay = this.factory.buildArmatureDisplay("car1");
                    ar.animation.gotoAndStop("ani");
                    ar.x = 552;
                    ar.y = 42;
                    this.addChild(ar);
                    this.ar = ar;
                    var ar2: dragonBones.EgretArmatureDisplay = this.factory.buildArmatureDisplay("car2");
                    ar2.animation.gotoAndStop("ani");
                    ar2.x = 637.5;
                    ar2.y = 919;
                    this.addChild(ar2);
                    this.ar2 = ar2;
                    var btn = new egret.Bitmap(RES.getRes("carLight1"));
                    btn.anchorOffsetX = btn.width / 2;
                    btn.anchorOffsetY = btn.height / 2;
                    btn.x = ar.x;
                    btn.y = ar.y;
                    this.addChild(btn);
                    btn.touchEnabled = true;
                    btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.game3start, this);
                    this.btn = btn;
                    var btn2 = new egret.Bitmap(RES.getRes("carLight2"));
                    btn2.anchorOffsetX = btn2.width / 2;
                    btn2.anchorOffsetY = btn2.height / 2;
                    btn2.x = ar2.x;
                    btn2.y = ar2.y;
                    this.addChild(btn2);
                    btn2.touchEnabled = true;
                    btn2.addEventListener(egret.TouchEvent.TOUCH_TAP, this.game3start, this);
                    this.btn2 = btn2;
                    var tw1 = egret.Tween.get(btn);
                    tw1.wait(200).to({alpha:0},0).wait(200).to({alpha:1},0).wait(200).to({alpha:0},0).wait(200).to({alpha:1},0).wait(200).to({alpha:0},0).wait(200).to({alpha:1},0).wait(200).to({alpha:0},0);
                    var tw2 = egret.Tween.get(btn2);
                    tw2.wait(200).to({alpha:0},0).wait(200).to({alpha:1},0).wait(200).to({alpha:0},0).wait(200).to({alpha:1},0).wait(200).to({alpha:0},0).wait(200).to({alpha:1},0).wait(200).to({alpha:0},0);
                    this.tw1=tw1;
                    this.tw2=tw2;
            }
            this.popTips(count + 1);
        }
        private popTips(count): void {
            var apt = new egret.Bitmap(RES.getRes("popGame" + count));
            apt.anchorOffsetX = apt.width / 2;
            apt.anchorOffsetY = apt.height / 2;
            apt.x = this.stageW / 2;
            apt.y = this.stageH / 2;
            apt.scaleX = apt.scaleY = .8;
            this.addChild(apt);
            var tw = egret.Tween.get(apt, { loop: false });
            tw.to({ scaleX: 1, scaleY: 1 }, 500, egret.Ease.bounceIn).wait(3000).call(function () {
               // this.disTips();
            }, this);
            this.tips = apt;
            this.tips.visible = true;
            apt.touchEnabled = true;
            apt.addEventListener(egret.TouchEvent.TOUCH_TAP, this.disTips, this);
        }
        private disTips(): void {
            this.tips.visible = false;
        }
        private game1start(): void {
            this.disTips();
            this.ar.animation.play("ani", 1);
            this.balloon.touchEnabled = false;
            var tw = egret.Tween.get(this.balloon);
            tw.to({ y: 162 }, 3100).wait(500).call(function () {
                this.gameDone(0);
            }, this);
        }
        private bingoError(evt: egret.TouchEvent): void {
            var tx: number = evt.localX;
            var ty: number = evt.localY;
            this.showError(tx,ty);
        }
        private showError(tx,ty):void{
            if(!this.tips.visible){
            var apt = new egret.Bitmap(RES.getRes("pointError"));
            apt.anchorOffsetX = apt.width / 2;
            apt.anchorOffsetY = apt.height / 2;
            apt.x = tx;
            apt.y = ty;
            //apt.scaleX = apt.scaleY = .8;
            this.addChild(apt);
            var tw = egret.Tween.get(apt, { loop: false });
            tw.wait(1000).to({ alpha: 0 }, 500).call(function () {
                this.removeChild(apt);
            }, this);
            }else{
                this.disTips();
            }
        }
        private game2check(event: egret.Event): void {
            this.disTips();
            var bx=event.target.x;
            //var check=10;
            //console.log(bx);
            for (var i = 0; i < this.btnsPos.length; i++) {
                //console.log(bx+'  '+this.btnsPos[i][0]);
                if(bx==this.btnsPos[i][0]){
                    var count=this.btnsPos[i][4];
                    if(this.bingoCheck[count]==0){
                        this.bingoCount++;
                        this.bingoCheck[count]=1;
                        
                       // check=count;
                    }
                    var apt = new egret.Bitmap(RES.getRes("bingo"));
                        apt.anchorOffsetX = apt.width / 2;
                        apt.anchorOffsetY = apt.height / 2;
                        apt.x = this.btnsPos[i][0];
                        apt.y = this.btnsPos[i][1]+event.target.height/2*event.target.scaleY+20;
                        this.addChild(apt);
                        if(this.bingoCount==this.bingoCheck.length){
                            this.gameDone(1);
                        }
                /*else{
                        this.showError(this.btnsPos[i][0],this.btnsPos[i][1]);
                    }*/
                    break;
                }
            }
            /*if (check < 10) {
                for (var i = 0; i < this.btnsPos.length; i++) {
                    //console.log(bx+'  '+this.btnsPos[i][0]);
                    if (check === this.btnsPos[i][4]) {

                    }
                }
            }*/
        }
        private game2start(): void {
            this.disTips();
            this.gameDone(1);
        }
        private game3start(event: egret.Event): void {
            this.tw1.setPaused(true);
            this.tw2.setPaused(true);
            this.tw1.pause();
            this.tw2.pause();
            //this.light1.alpha=0;
            //this.light2.alpha=0;
            this.disTips();
            this.btn.visible = false;
            this.btn2.visible = false;
            if (event.target.y < 500) {
                this.ar.animation.play("ani", 1);
                this.ar.addEventListener(dragonBones.AnimationEvent.COMPLETE, this.car1done, this);
            } else {
                this.ar2.animation.play("ani", 1);
                this.ar2.addEventListener(dragonBones.AnimationEvent.COMPLETE, this.car2done, this);
            }
            egret.setTimeout(this.gameDone, this, 6000, 2);
        }
        private car1done(): void {
            this.ar2.animation.play("ani", 1);
        }
        private car2done(): void {
            this.ar.animation.play("ani", 1);
        }
        private gameDone(count): void {
            var dark = new egret.Bitmap(RES.getRes("darkness"));
            this.addChild(dark);
            dark.touchEnabled = true;
            this.points[count] = 1;
            var apt = new egret.Bitmap(RES.getRes("popDone"+(count+1)));
            apt.anchorOffsetX = apt.width / 2;
            apt.anchorOffsetY = apt.height / 2;
            apt.x = this.stageW / 2;
            apt.y = this.stageH / 2;
            apt.scaleX = apt.scaleY = .8;
            this.addChild(apt);
            var tw = egret.Tween.get(apt, { loop: false });
            tw.to({ scaleX: 1, scaleY: 1 }, 500, egret.Ease.bounceIn);
            var btn = new egret.Bitmap(RES.getRes("btnBack"));
            btn.anchorOffsetX = btn.width / 2;
            btn.anchorOffsetY = btn.height / 2;
            btn.x = apt.x;
            btn.y = apt.y + apt.height / 2+btn.height / 2+50;
            this.addChild(btn);
            btn.touchEnabled = true;
            btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.showPoints, this);
        }
    }


}